package org.cheetah.core.exchange;

import java.io.Serializable;

public class Exchange implements Serializable {
	private static final long serialVersionUID = 2722839646850923211L;

	private Message in;

	private Message out;

	private Throwable fault;

	public Exchange(Message in) {
		this.in = in;
		this.out = null;
		this.fault = null;
	}

	public void setIn(Message in) {
		this.in = in;
	}

	public Message getIn() {
		return in;
	}

	public void setOut(Message out) {
		this.out = out;
	}

	public Message getOut() {
		return out;
	}

	public void setFault(Throwable t) {
		this.fault = t;
	}

	public Throwable getFault() {
		return fault;
	}

	public boolean hasOut() {
		return out != null;
	}

	public boolean hasFault() {
		return fault != null;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();

		sb.append(super.toString()).append("\nmessage-in\n").append(in).append(
				"\nmessage-out\n").append(out).append("\nmessage-fault\n")
				.append(fault);

		return sb.toString();
	}
}
